package com.greyshark.sanotrive.utils

import android.annotation.SuppressLint
import android.os.CountDownTimer
import android.widget.TextView

/**
 * 作者：sosou
 * <p>
 * 版本：1.0
 * <p>
 * 创建日期：2022/8/20
 * <p>
 * 描述：
 * <p>
 * 修订历史：
 */
class SplashCountDownTimer(
    millisInFuture: Long,
    countDownInterval: Long,
    private val textView: TextView?
) : CountDownTimer(millisInFuture, countDownInterval) {

    override fun onFinish() {
        textView?.text = "0 跳过"
        onFinishListener?.onFinish()
    }

    @SuppressLint("SetTextI18n")
    override fun onTick(millisUntilFinished: Long) {
        val time = millisUntilFinished / 1000
        textView?.text = "${time + 1} 跳过"
    }

    private var onFinishListener: OnFinishListener? = null
    fun setOnFinishListener(onFinishListener: OnFinishListener) {
        this.onFinishListener = onFinishListener
    }

    interface OnFinishListener {
        fun onFinish()
    }
}
